/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-02-07
*/
package com.zjmzxfzhl.modules.app.controller;

import com.zjmzxfzhl.common.core.Result;
import com.zjmzxfzhl.common.core.base.BaseController;
import com.zjmzxfzhl.modules.app.form.Chunk;
import com.zjmzxfzhl.modules.app.util.BigFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.UUID;

/**
 * 文件表控制层
 *
 * @author Rzico Boot
 * @version 1.0
 * @date 2020-02-07
 */
@Slf4j
@RestController
@RequestMapping("/app/file")
public class AppFileController extends BaseController {

    @Autowired
    private BigFileService bigFileService;

    /**
     * 上传大文到文件夹
     */
    @PostMapping("/uploadBigFile")
    public String uploadBigFile(@ModelAttribute Chunk chunk, HttpServletResponse response) {

        if (chunk.getFile()==null) {
            System.out.println("exception:File Is Null");
            return "exception:File Is Null";
        }

        log.error("getChunkNumber="+String.valueOf(chunk.getIndex()));
        log.error("getFilename="+String.valueOf(chunk.getName()));
        log.error("getIdentifier="+String.valueOf(chunk.getCode()));
        log.error("getTotalChunks="+String.valueOf(chunk.getTotal()));
        return bigFileService.fileUpload(chunk,response);

    }
}
